package com.mjf.jst.enums;

import cn.hutool.core.collection.ListUtil;
import lombok.Getter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * desc  聚水潭API枚举
 * </p>
 *https://openweb.jushuitan.com/dev-doc?docType=8&docId=34
 * @author chenshoumeng
 * @date 2025/5/18 02:00
 */
@Getter
public enum JSTApiEnum {

    SHOP_QUERY("501", "店铺查询", "/open/shops/query", ListUtil.of(), ""),
    SALESOUT_QUERY("502", "销售出库查询", "/open/orders/out/simple/query", ListUtil.of(), ""),
    PRODUCT_QUERY("503", "普通商品资料查询", "/open/sku/query", ListUtil.of("skuCode"), ""),
    WAREHOUSE_QUERY("504", "仓库查询", "/open/wms/partner/query", ListUtil.of("warehouseCode"), ""),
    ;

    private static final Map<String, JSTApiEnum> LOOKUP_MAP = new HashMap<>(4, 1);

    static {
        for (JSTApiEnum cstEnum : JSTApiEnum.values()) {
            LOOKUP_MAP.put(cstEnum.codes, cstEnum);
        }
    }

    JSTApiEnum(String codes, String name, String url, List<String> filedList, String filedString) {
        this.codes = codes;
        this.name = name;
        this.url = url;
        this.filedList = filedList;
        this.filedString = filedString;
    }

    /**
     * -- GETTER --
     *
     * @return 枚举值
     */
    private String codes;
    private String name;
    private String url;
    private List<String> filedList;
    private String filedString;


    /**
     * 根据枚举值获取枚举
     *
     * @param codes codes
     * @return 若枚举值存在，返回对应的枚举，否则返回 null
     */
    public static JSTApiEnum formValue(String codes) {
        return LOOKUP_MAP.get(codes);
    }


}
